package com.itheima.controller;

import com.itheima.dto.SetmealDto;
import com.itheima.entry.PageResult;
import com.itheima.entry.QueryPageBean;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author jshstart
 * @creat 2020-11-13 17:34
 */
@RestController
@RequestMapping("/Setmeal")
public class SetmealController {
    @Reference
    private SetmealService setmealService;
    @PostMapping("/findAllByPage")
    public PageResult findAllByPage(@RequestBody QueryPageBean queryPageBean){
        System.out.println("queryPageBean = " + queryPageBean);
       PageResult pageResult= setmealService.findAllByPage(queryPageBean);
       return pageResult;
    }
    @PostMapping("/save")
    public void save(@RequestBody SetmealDto setmealDto){
        setmealService.addAndUpdate(setmealDto);
    }
    @GetMapping("findAllIds/{id}")
    public Long[] findAllIds(@PathVariable("id") Long id){
        System.out.println("id = " + id);
        Long[] groupIds= setmealService.findAllIds(id);
       return groupIds;
    }
    @GetMapping("deleteById/{id}")
    public void deleteById(@PathVariable("id") Long id){
        setmealService.deleteById(id);
    }
    @GetMapping("/findAll")
    public List<Setmeal> findAll(){
       return setmealService.findAll();
    }
    @GetMapping("/clearOssObject")
    public void clearOssObject(){

        setmealService.clearOssObject();
    }
}
